package src.linkeLlist;

public class no141 {
    //判断是否为环形链表
    public boolean hasCycle(ListNode head) {
        ListNode slow = head, fast = head;
        //快指针走两步，满指针走一步
        while (fast != null && fast.next != null) {
            slow = slow.next;
            fast = fast.next.next;
            if (slow == fast) {
                return true;
            }
        }
        return false;

    }
}
